/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ceair.flight.refund.location.dt.enums;

import java.math.RoundingMode;

/**
 *
 * @author Colin_You
 */
public enum CurrencyEnum {

    KRW {
        @Override
        public int getScale() {
            //韩元是100位的精度
            return -2;
        }

        @Override
        public RoundingMode getProfitableMode() {
            return RoundingMode.UP;
        }

        @Override
        public RoundingMode getLossMode() {
            return RoundingMode.DOWN;
        }
    },
    JPY {
        @Override
        public int getScale() {
            //日元是10位的精度
            return -1;
        }

        @Override
        public RoundingMode getProfitableMode() {
            return RoundingMode.UP;
        }

        @Override
        public RoundingMode getLossMode() {
            return RoundingMode.DOWN;
        }
    },
    TWD {
        @Override
        public int getScale() {
            //台币是个位的精度
            return 0;
        }

        @Override
        public RoundingMode getProfitableMode() {
            return RoundingMode.UP;
        }

        @Override
        public RoundingMode getLossMode() {
            return RoundingMode.DOWN;
        }
    },
    NULL;//默认不存在的货币类型

    /**
     * 默认是小数点后两位的精度
     *
     * @return
     */
    public int getScale() {
        return 2;
    }

    /**
     * 默认从获利的角度上看, 在精度上进行四舍五入向上
     *
     * @return
     */
    public RoundingMode getProfitableMode() {
        return RoundingMode.HALF_UP;
    }

    /**
     * 从让乘客吃亏的角度看, 在精度上进行四舍五入向下
     *
     * @return
     */
    public RoundingMode getLossMode() {
        return RoundingMode.HALF_DOWN;
    }
}
